package com.hotelsystem.dao;

import com.hotelsystem.pojo.Employee;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface EmployeeMapper {
    /**
     * 通过员工对象 查询员工信息
     * @param employee
     * @return
     */
    List<Employee> getAllEmployee(Employee employee);

    @Delete("DELETE from t_employee where username =  #{empName}")
    void deleteEmpInfoByName(String empName);

    /**
     * 添加员工信息
     * @param employee
     */
    @Insert("INSERT INTO t_employee VALUES(null,#{username},#{password},#{headImage},#{sex},#{realName},#{phone},#{creator},#{createDate},#{role.roleId},#{status})")
    void addEmpInfo(Employee employee);

    /**
     * 修改员工信息
     * @param employee
     */
    @Update("UPDATE t_employee set password=#{password},head_image=#{headImage},sex=#{sex},real_name=#{realName},phone=#{phone},role_id=#{role.roleId},status=#{status} where username=#{username}")
    void updateEmpInfoByName(Employee employee);

    /**
     * 通过userName查询单个信息
     * @param username
     * @return
     */
    Employee getEmpInfoByuserName(String username);

    /**
     *  根据id修改密码
     * @param empId
     * @param password
     * @return
     * @throws Exception
     */
    @Update("update t_employee set password=#{password} where emp_id=#{empId}")
    Integer update(Integer empId,String password) throws Exception;
}